package org.googlecode.jwf.demo;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import per.edward.wizard.ext.CustomDescriptor;
import per.edward.wizard.ext.WizardPanelProblemDisplayer;

public class ConnectorTypeDesc extends CustomDescriptor {

    private ConnectorTypePanel contentPane_ = new ConnectorTypePanel();

    public ConnectorTypeDesc() {
        setPanelDescriptorIdentifier(ConnectorTypePanel.class.getName());
        setWrappedPanelComponent(contentPane_);
        contentPane_.addPropertyChangeListener("agreementChecked",
                new PropertyChangeListener() {
                    public void propertyChange(PropertyChangeEvent e) {
                        agreementCheckedChanged(contentPane_
                                .getAgreementChecked());
                    }
                });
    }

    private void agreementCheckedChanged(boolean newValue) {
        if (newValue == true) {
            clearProblem();
        } else {
            setProblem(WizardPanelProblemDisplayer.PROBLEM_INFO,
                    "The 'Next' button is disabled until you check the box above.");
        }
    }

    @Override
    public void aboutToDisplayPanel() {
        agreementCheckedChanged(contentPane_.getAgreementChecked());
    }
}
